package com.example.demo.exception;

import com.example.demo.result.Result;
import com.example.demo.result.ResultUtils;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    @ResponseStatus(code = HttpStatus.OK)
    public Result handleException(Exception e){
        return ResultUtils.fail(e.getMessage());
    }
}
